package net.huashitong.ssydt.provider.money.controller.ssMoneyVipController;


import net.huashitong.ssydt.money.entity.vo.SsMoneyVipRecordInVO;
import net.huashitong.ssydt.provider.money.controller.ClientUtils;
import net.huashitong.user.http.Result;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author hemj
 * @version 2017/8/22
 */
public class RenewalEffectiveDay {

	private static final String VALID_USER_ID = "20170817100000000026";

	@Test
	public void successInc() {
		SsMoneyVipRecordInVO ssMoneyVipRecordInVO = new SsMoneyVipRecordInVO();
		ssMoneyVipRecordInVO.setUserId(VALID_USER_ID);
		ssMoneyVipRecordInVO.setEffectiveDay(10);
		ssMoneyVipRecordInVO.setRemarks("后台vip套餐修改");

		String url = TestUtils.getUrl(VALID_USER_ID);
		Result<String> result = ClientUtils.clientManager.putFormData(url, ssMoneyVipRecordInVO);
		System.out.println(result);
		assertEquals(Result.Status.SUCCESS, result.getCode());
	}

	@Test
	public void validateFailure() {
		SsMoneyVipRecordInVO ssMoneyVipRecordInVO = new SsMoneyVipRecordInVO();
		String url = TestUtils.getUrl(VALID_USER_ID);
		Result<String> result = ClientUtils.clientManager.putFormData(url, ssMoneyVipRecordInVO);
		System.out.println(result);
		assertEquals(Result.Status.PARAM_ERROR, result.getCode());
	}

	@Test
	public void invalidUserId() {
		SsMoneyVipRecordInVO ssMoneyVipRecordInVO = new SsMoneyVipRecordInVO();
		ssMoneyVipRecordInVO.setUserId("123");
		ssMoneyVipRecordInVO.setEffectiveDay(10);
		ssMoneyVipRecordInVO.setRemarks("后台vip套餐修改");

		String url = TestUtils.getUrl("123");
		Result<String> result = ClientUtils.clientManager.putFormData(url, ssMoneyVipRecordInVO);
		System.out.println(result);
		assertEquals(Result.Status.ERROR, result.getCode());
		assertEquals(true, result.getMessage().contains("用户的账户不存在"));
	}

}
